// components/vae-board/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    boardData: {
      type: Object,
      value: {
        image: "/assets/img/message/mountain.png",
        likeCount: 128,
        avatar: "/assets/img/profile/profile.png",
        username: "城旅小助手",
        content: "发现城市美好，分享生活点滴",
        time: "2024-01-15 14:30"
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    onBoardTap: function(e) {
      const boardData = this.properties.boardData
      
      wx.showModal({
        title: boardData.username,
        content: boardData.content + '\n\n发布时间：' + boardData.time,
        showCancel: true,
        cancelText: '关闭',
        confirmText: '查看详情',
        success: function(res) {
          if (res.confirm) {
            wx.showToast({
              title: '详情页面开发中',
              icon: 'none'
            })
          }
        }
      })
    },
    
    onLikeTap: function(e) {
      e.stopPropagation()
      const boardData = this.properties.boardData
      const newLikeCount = boardData.likeCount + 1
      
      this.triggerEvent('like', {
        likeCount: newLikeCount
      })
      
      wx.showToast({
        title: '点赞成功',
        icon: 'success'
      })
    },
    
    onAvatarTap: function(e) {
      e.stopPropagation()
      const boardData = this.properties.boardData
      
      wx.showToast({
        title: '查看' + boardData.username + '的主页',
        icon: 'none'
      })
    }
  }
})
